package cn.lichenes.controller;

import cn.lichenes.service.PhoneService;
import cn.lichenes.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
public class IndexController {

    @Autowired
    private PhoneService PhoneService;
    @Autowired
    private UserService userService;

    @GetMapping("/management-index")
    public String managmentIndex(Model model){
        Map<String, Object> map = userService.getIndex();
        model.addAllAttributes(map);
        return "management-index";
    }

    @PostMapping("/echarts")
    @ResponseBody
    public List<Map<String, Object>> echarts(){
        return PhoneService.getEcharts();
    }
}
